/**
 *
 * @description:tab切换
 * @author:junyong.hong
 * @createTime:2017/12/7
 * @version:1.0.0.0
 * @history:
 *    1、
 *    2、
 *
 */
define([
    'angularAMD',
    'config'
], function (angularAMD, app) {
    app.provider('tabRouter', function ($stateProvider, $urlRouterProvider) {

        this.$get = function () {
            var service, CURRENT_PATH = 'components/module/tab/';

            service = {
                'setRouter': function () {
                    $stateProvider
                        //state.includes案例
                        .state('index.tab', angularAMD.route({
                            url:'/tab',
                            templateUrl:CURRENT_PATH + 'stateIncludes/tab.html',
                            controllerAs:'tabVM',
                            controllerUrl:CURRENT_PATH + 'stateIncludes/tab.controller.js',
                            controller:'tab.controller'
                        }))
                        .state('index.tab.page1', angularAMD.route({
                            url:'/page1',
                            templateUrl:CURRENT_PATH + 'stateIncludes/page1.html'
                        }))
                        .state('index.tab.page2', angularAMD.route({
                            url:'/page2',
                            templateUrl:CURRENT_PATH + 'stateIncludes/page2.html'
                        }))
                        .state('index.tab.page3', angularAMD.route({
                            url:'/page3',
                            templateUrl:CURRENT_PATH + 'stateIncludes/page3.html'
                        }))

                        // ng-include案例
                        .state('index.ngInclude', angularAMD.route({
                            url:'/ngInclude',
                            templateUrl:CURRENT_PATH + 'ngInclude/ngInclude.html',
                            controllerAs:'vm',
                            controllerUrl:CURRENT_PATH + 'ngInclude/ngInclude.controller.js',
                            controller:'ngInclude.controller'
                        }))

                        // ng-include案例优化：tab切换，页面数据不会丢失
                        .state('index.ngInclude2', angularAMD.route({
                            url:'/ngInclude2',
                            templateUrl:CURRENT_PATH + 'ngInclude2/ngInclude2.html',
                            controllerAs:'vm',
                            controllerUrl:CURRENT_PATH + 'ngInclude2/ngInclude2.controller.js',
                            controller:'ngInclude2.controller'
                        }))
                }
            };
            return service;
        }
    }).run(function (tabRouter) {
        tabRouter.setRouter();
    });
});
